package com.bbx.taxi.client.Service;

import com.bbx.taxi.client.Listener.TimeTickReceiver;

import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;

/** 
 * @Path com.bbx.taxi.client.Service.TimeService.java
 * @Author 严旭文
 * @Date 2016-1-7 下午5:22:19
 * @Company 蓝海（福建）信息技术有限公司
 * @Description
 * 服务 用于  注册 监听时间变化、设置的广播   时间变化广播只能动态注册 
 */
public class TimeService extends Service {  
    
  //监听时间变化的 这个receiver只能动态创建  
  private TimeTickReceiver mTickReceiver;  
  private IntentFilter mFilter;  

  @Override  
  public IBinder onBind(Intent intent) {  
      return null;  
  }  
    
  @Override  
  public void onCreate() {  
      super.onCreate();  
      mFilter = new IntentFilter();  
      mFilter.addAction(Intent.ACTION_TIME_TICK); //每分钟变化的action  
      mFilter.addAction(Intent.ACTION_TIME_CHANGED); //设置了系统时间的action  
      mTickReceiver = new TimeTickReceiver();  
      registerReceiver(mTickReceiver, mFilter);   
  }  
    
  @Override  
  public int onStartCommand(Intent intent, int flags, int startId) {  
      return Service.START_STICKY;  
  }  
    
  @Override  
  public void onDestroy() {  
      super.onDestroy();  
      unregisterReceiver(mTickReceiver);  
  }  
}  